+2005-05-07 Owen Taylor <otaylor@redhat.com>
+
+ * gdk/gdkpixbuf-render.c gdk/gdkpixbuf.h (gdk_pixbuf_set_as_cairo_source):
+ Change prototype to match cairo_set_source_surface().
+
+ * gdk/gdkdraw.c gdk/gdkgc.c gdk/gdkpixbuf-render.c gdk/gdkwindow.c
+ gtk/gtkhsv.c tests/testcairo.c.
+
2005-05-06 Federico Mena Quintero <federico@ximian.com>
Merged from gtk-2-6:
+2005-05-07 Owen Taylor <otaylor@redhat.com>
+
+ * gdk/gdkpixbuf-render.c gdk/gdkpixbuf.h (gdk_pixbuf_set_as_cairo_source):
+ Change prototype to match cairo_set_source_surface().
+
+ * gdk/gdkdraw.c gdk/gdkgc.c gdk/gdkpixbuf-render.c gdk/gdkwindow.c
+ gtk/gtkhsv.c tests/testcairo.c.
+
2005-05-06 Federico Mena Quintero <federico@ximian.com>
Merged from gtk-2-6:
+2005-05-07 Owen Taylor <otaylor@redhat.com>
+
+ * gdk/gdkpixbuf-render.c gdk/gdkpixbuf.h (gdk_pixbuf_set_as_cairo_source):
+ Change prototype to match cairo_set_source_surface().
+
+ * gdk/gdkdraw.c gdk/gdkgc.c gdk/gdkpixbuf-render.c gdk/gdkwindow.c
+ gtk/gtkhsv.c tests/testcairo.c.
+
2005-05-06 Federico Mena Quintero <federico@ximian.com>
Merged from gtk-2-6:
if (matrix)
{
- cairo_matrix_t *cairo_matrix;
-
- cairo_matrix = cairo_matrix_create ();
- cairo_matrix_set_affine (cairo_matrix,
- matrix->xx, matrix->yx,
- matrix->xy, matrix->yy,
- matrix->x0, matrix->y0);
+ cairo_matrix_t cairo_matrix;
+
+ cairo_matrix.xx = matrix->xx;
+ cairo_matrix.yx = matrix->yx;
+ cairo_matrix.xy = matrix->xy;
+ cairo_matrix.yy = matrix->yy;
+ cairo_matrix.x0 = matrix->x0;
+ cairo_matrix.y0 = matrix->y0;
- cairo_set_matrix (cr, cairo_matrix);
- cairo_matrix_destroy (cairo_matrix);
+ cairo_set_matrix (cr, &cairo_matrix);
}
cairo_move_to (cr, x, y);
g_return_val_if_fail (GDK_IS_DRAWABLE (drawable), NULL);
- cr = cairo_create ();
-
surface = _gdk_drawable_ref_cairo_surface (drawable);
- if (surface)
- cairo_set_target_surface (cr, surface);
+ cr = cairo_create (surface);
+ cairo_surface_destroy (surface);
return cr;
}
alpha_surface = _gdk_drawable_ref_cairo_surface (stipple);
- surface = cairo_surface_create_similar (cairo_get_target_surface (cr),
+ surface = cairo_surface_create_similar (cairo_get_target (cr),
CAIRO_FORMAT_ARGB32,
width, height);
- tmp_cr = cairo_create ();
- cairo_set_target_surface (tmp_cr, surface);
+ tmp_cr = cairo_create (surface);
- cairo_set_operator (tmp_cr, CAIRO_OPERATOR_SRC);
+ cairo_set_operator (tmp_cr, CAIRO_OPERATOR_SOURCE);
if (background)
gdk_cairo_set_source_color (tmp_cr, background);
* gdk_pixbuf_set_as_cairo_source:
* @pixbuf: a #GdkPixbuf
* @cr: a #Cairo context
+ * @pixbuf_x: X coordinate of location to place upper left corner of @pixbuf
+ * @pixbuf_y: Y coordinate of location to place upper left corner of @pixbuf
*
* Sets the given pixbuf as the source pattern for the Cairo context.
* The pattern has an extend mode of %CAIRO_EXTEND_NONE and is aligned
- * so that the origin of @pixbuf is at the current point.
+ * so that the origin of @pixbuf is @pixbuf_x, @pixbuf_y
**/
void
gdk_pixbuf_set_as_cairo_source (GdkPixbuf *pixbuf,
- cairo_t *cr)
+ cairo_t *cr,
+ double pixbuf_x,
+ double pixbuf_y)
{
gint width = gdk_pixbuf_get_width (pixbuf);
gint height = gdk_pixbuf_get_height (pixbuf);
guchar *cairo_pixels;
cairo_format_t format;
cairo_surface_t *surface;
- cairo_pattern_t *pattern;
static const cairo_user_data_key_t key;
- cairo_matrix_t *matrix;
- double x, y;
int j;
if (n_channels == 3)
cairo_pixels += 4 * width;
}
- pattern = cairo_pattern_create_for_surface (surface);
- cairo_surface_destroy (surface);
-
- cairo_current_point (cr, &x, &y);
- matrix = cairo_matrix_create ();
- cairo_matrix_translate (matrix, -x, -y);
- cairo_pattern_set_matrix (pattern, matrix);
- cairo_matrix_destroy (matrix);
-
- cairo_set_source (cr, pattern);
- cairo_pattern_destroy (pattern);
+ cairo_set_source_surface (cr, surface, pixbuf_x, pixbuf_y);
}
#define __GDK_PIXBUF_RENDER_C__
int height);
void gdk_pixbuf_set_as_cairo_source (GdkPixbuf *pixbuf,
- cairo_t *cr);
+ cairo_t *cr,
+ double pixbuf_x,
+ double pixbuf_y);
G_END_DECLS
if (x_offset != 0 || y_offset)
{
- cairo_matrix_t *matrix = cairo_matrix_create ();
- cairo_matrix_translate (matrix, x_offset, y_offset);
- cairo_pattern_set_matrix (pattern, matrix);
- cairo_matrix_destroy (matrix);
+ cairo_matrix_t matrix;
+ cairo_matrix_init_translate (&matrix, x_offset, y_offset);
+ cairo_pattern_set_matrix (pattern, &matrix);
}
cairo_pattern_set_extend (pattern, CAIRO_EXTEND_REPEAT);
if (GDK_WINDOW_DESTROYED (window))
return;
- cr = cairo_create ();
- cairo_set_target_surface (cr, paint->surface);
+ cr = cairo_create (paint->surface);
gdk_window_set_bg_pattern (window, cr, 0, 0);
/* Redrawing */
-static void
-set_source_surface (cairo_t *cr,
- cairo_surface_t *surface)
-{
- cairo_pattern_t *pattern;
- cairo_matrix_t *matrix;
- double x, y;
-
- pattern = cairo_pattern_create_for_surface (surface);
-
- cairo_current_point (cr, &x, &y);
- matrix = cairo_matrix_create ();
- cairo_matrix_translate (matrix, -x, -y);
- cairo_pattern_set_matrix (pattern, matrix);
- cairo_matrix_destroy (matrix);
-
- cairo_set_source (cr, pattern);
- cairo_pattern_destroy (pattern);
-}
-
/* Paints the hue ring */
static void
paint_ring (GtkHSV *hsv,
/* Now draw the value marker onto the source image, so that it
* will get properly clipped at the edges of the ring
*/
- source_cr = cairo_create ();
- cairo_set_target_surface (source_cr, source);
+ source_cr = cairo_create (source);
r = priv->h;
g = 1.0;
cairo_save (cr);
- cairo_move_to (cr, x, y);
- set_source_surface (cr, source);
+ cairo_set_source_surface (cr, source, x, y);
cairo_surface_destroy (source);
cairo_set_line_width (cr, priv->ring_width);
/* Draw a triangle with the image as a source */
- cairo_move_to (cr, x, y);
- set_source_surface (cr, source);
+ cairo_set_source_surface (cr, source, x, y);
cairo_surface_destroy (source);
cairo_move_to (cr, x1, y1);
double xc, double yc,
double xr, double yr)
{
- cairo_matrix_t *matrix;
-
- matrix = cairo_matrix_create ();
- cairo_current_matrix (cr, matrix);
+ cairo_save (cr);
cairo_translate (cr, xc, yc);
cairo_scale (cr, 1.0, yr / xr);
0, 2 * G_PI);
cairo_close_path (cr);
- cairo_set_matrix (cr, matrix);
- cairo_matrix_destroy (matrix);
+ cairo_restore (cr);
}
/* Create a path that is a circular oval with radii xr, yr at xc,
int height)
{
cairo_surface_t *overlay, *punch, *circles;
+ cairo_t *overlay_cr, *punch_cr, *circles_cr;
/* Fill the background */
double radius = 0.5 * (width < height ? width : height) - 10;
double xc = width / 2.;
double yc = height / 2.;
- overlay = cairo_surface_create_similar (cairo_current_target_surface (cr),
+ overlay = cairo_surface_create_similar (cairo_get_target (cr),
CAIRO_FORMAT_ARGB32,
width, height);
if (overlay == NULL)
return;
- punch = cairo_surface_create_similar (cairo_current_target_surface (cr),
+ punch = cairo_surface_create_similar (cairo_get_target (cr),
CAIRO_FORMAT_A8,
width, height);
if (punch == NULL)
return;
- circles = cairo_surface_create_similar (cairo_current_target_surface (cr),
+ circles = cairo_surface_create_similar (cairo_get_target (cr),
CAIRO_FORMAT_ARGB32,
width, height);
if (circles == NULL)
fill_checks (cr, 0, 0, width, height);
- cairo_save (cr);
- cairo_set_target_surface (cr, overlay);
- cairo_identity_matrix (cr);
-
/* Draw a black circle on the overlay
*/
- cairo_set_source_rgb (cr, 0., 0., 0.);
- oval_path (cr, xc, yc, radius, radius);
- cairo_fill (cr);
-
- cairo_save (cr);
- cairo_set_target_surface (cr, punch);
+ overlay_cr = cairo_create (overlay);
+ cairo_set_source_rgb (overlay_cr, 0., 0., 0.);
+ oval_path (overlay_cr, xc, yc, radius, radius);
+ cairo_fill (overlay_cr);
/* Draw 3 circles to the punch surface, then cut
* that out of the main circle in the overlay
*/
- draw_3circles (cr, xc, yc, radius, 1.0);
-
- cairo_restore (cr);
+ punch_cr = cairo_create (punch);
+ draw_3circles (punch_cr, xc, yc, radius, 1.0);
+ cairo_destroy (punch_cr);
- cairo_set_operator (cr, CAIRO_OPERATOR_OUT_REVERSE);
- cairo_set_source_surface (cr, punch, 0, 0);
- cairo_paint (cr);
+ cairo_set_operator (overlay_cr, CAIRO_OPERATOR_DEST_OUT);
+ cairo_set_source_surface (overlay_cr, punch, 0, 0);
+ cairo_paint (overlay_cr);
/* Now draw the 3 circles in a subgroup again
* at half intensity, and use OperatorAdd to join up
* without seams.
*/
- cairo_save (cr);
- cairo_set_target_surface (cr, circles);
-
- cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
- draw_3circles (cr, xc, yc, radius, 0.5);
-
- cairo_restore (cr);
+ circles_cr = cairo_create (circles);
+
+ cairo_set_operator (circles_cr, CAIRO_OPERATOR_OVER);
+ draw_3circles (circles_cr, xc, yc, radius, 0.5);
+ cairo_destroy (circles_cr);
- cairo_set_operator (cr, CAIRO_OPERATOR_ADD);
- cairo_set_source_surface (cr, circles, 0, 0);
- cairo_paint (cr);
+ cairo_set_operator (overlay_cr, CAIRO_OPERATOR_ADD);
+ cairo_set_source_surface (overlay_cr, circles, 0, 0);
+ cairo_paint (overlay_cr);
- cairo_restore (cr);
+ cairo_destroy (overlay_cr);
cairo_set_source_surface (cr, overlay, 0, 0);
cairo_paint (cr);